﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace _3TierDemo.DAL
{
    class CommonDAO
    {
        private string strConnect;
        public string StrConnect
        {
            get { return strConnect; }
            set { strConnect = value; }
        }
        public CommonDAO()
        {
            StrConnect = "server=.;uid=sa;pwd=1234$;database=qlsv";
        }
        protected bool execNonQuery(string strQuery)
        {           
            bool check = true;
            try
            {
                SqlConnection con = new SqlConnection(StrConnect);
                con.Open();               
                SqlCommand com = new SqlCommand(strQuery, con);
                com.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception ex)
            {
                check = false;
            }
            return check;
        }

        protected DataTable execSelect(string strSelect)
        {
            SqlConnection con = new SqlConnection(StrConnect);
            con.Open();            
            SqlDataAdapter da = new SqlDataAdapter(strSelect, con);
            DataTable dt = new DataTable();
            da.Fill(dt);
            con.Close();
            return dt;
        }
    }
}
